package bankingSystemServer;

public class ServerTextInterface extends ServerInterface {

	/**
	 * creates a ServerTextInterface object
	 * 
	 * @param option
	 *            represents which type of Server to use
	 */
	public ServerTextInterface(int option) {
		super(option);
	}

	/**
	 * main
	 * 
	 * @param args
	 *            the argument is a number representing which type of Server to
	 *            use
	 */
	public static void main(String args[]) {

		int option = 0;
		ServerTextInterface serverInterface = null;

		if (args.length == 1) {
			option = Integer.parseInt(args[0]);
			serverInterface = new ServerTextInterface(option);
		} else if (args.length == 0) {
			serverInterface = new ServerTextInterface(1);
		} else {
			printUsage();
			System.exit(0);
		}

		if (serverInterface != null) {
			serverInterface.run();
		}

		System.exit(0);

	}

	/**
	 * prints the usage
	 */
	public static void printUsage() {
		String usage = "usage: ServerTextInterface -type\n";
		usage += "where type = 1,2,3,4\n";
		usage += "1 - single thread\n";
		usage += "2 - dyanmic creation\n";
		usage += "3 - half sync - half async\n";
		usage += "4 - leader follower\n";
		usage += "default type is single thread";
		System.out.println(usage);
	}

	@Override
	public void run() {
		server.run();
	}
}
